<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="OWNER_INFO_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="REDIRECT_URL_KEY" scope="page" />
<atleap:content identifier="information" ignore="true" />

<atleap:isUserInRole roles="core-contentField-update, core-contentField-updateOverriden, core-contentField-updateIndexed" var="canUpdate" />

<c:set var="justChooseLocales" value="${!empty sessionScope[pageScope.REDIRECT_URL_KEY]}" scope="request" />

<table cellpadding="0" cellspacing="0" border="0" class="tableView">
    <tr>
	    <th><atleap:message key="core.contentField.form.ownerInfo" /></th>
	    <td>${sessionScope[pageScope.OWNER_INFO_KEY]}</td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.contentField.form.identifier" /></th>
        <td><c:out value="${requestScope.contentField.identifier}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.contentField.form.type" /></th>
        <td><atleap:message key="core.contentField.form.type.${requestScope.contentField.type}" /></td>
    </tr>
</table>
<atleap:form action="core/contentField/callUpdate" method="GET" validateOnSubmit="false">
    <html:hidden property="id" value="${requestScope.contentField.id}" />

    <c:if test="${canUpdate && requestScope.updateAllowed}">
        <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.callUpdate" /></atleap:submit>
    </c:if>

    <html:hidden property="ownerId" value="${requestScope.contentField.owner.id}" />
    <atleap:cancel styleClass="button">
        <c:choose>
            <c:when test="${justChooseLocales}">
                <atleap:message key="core.commons.buttons.cancel" />
            </c:when>
            <c:otherwise>
                <atleap:message key="core.commons.buttons.showList" />
            </c:otherwise>
        </c:choose>
    </atleap:cancel>
</atleap:form>

<atleap:isUserInRole roles="core-contentFieldValue-list">
    <%-- List of content field values for this content field --%>
    <c:set var="contentFieldId" value="${requestScope.contentField.id}" scope="request" />
    <h3>
        <atleap:message key="core.contentFieldValue.list" />
    </h3>
    <tiles:get name="listContentFieldValues" />
</atleap:isUserInRole>
